package com.iot.nev.gateway.connector.hbase;

import java.io.IOException;

public class TestHBase {
	public static void main(String[] args) {
		int workTime = 1000;
		long startTime = System.currentTimeMillis();
		Thread t1 = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					long duration = 0;
					do {
						SaveDataForHBase.saveData("");
						duration = System.currentTimeMillis() - startTime;
					} while (duration < workTime);
					System.out.println("1用时：" + duration);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		});

		Thread t2 = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					long duration = 0;
					do {
						SaveDataForHBase.saveData("");
						duration = System.currentTimeMillis() - startTime;
					} while (duration < workTime);
					System.out.println("2用时：" + duration);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		});
		Thread t3 = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					long duration = 0;
					do {
						SaveDataForHBase.saveData("");
						duration = System.currentTimeMillis() - startTime;
					} while (duration < workTime);
					System.out.println("3用时：" + duration);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		});
		Thread t4 = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					long duration = 0;
					do {
						SaveDataForHBase.saveData("");
						duration = System.currentTimeMillis() - startTime;
					} while (duration < workTime);
					System.out.println("4用时：" + duration);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		});
		Thread t5 = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					long duration = 0;
					do {
						SaveDataForHBase.saveData("");
						duration = System.currentTimeMillis() - startTime;
					} while (duration < workTime);
					System.out.println("5用时：" + duration);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		});
		Thread t6 = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					long duration = 0;
					do {
						SaveDataForHBase.saveData("");
						duration = System.currentTimeMillis() - startTime;
					} while (duration < workTime);
					System.out.println("6用时：" + duration);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		});
		Thread t7 = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					long duration = 0;
					do {
						SaveDataForHBase.saveData("");
						duration = System.currentTimeMillis() - startTime;
					} while (duration < workTime);
					System.out.println("7用时：" + duration);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		});
		Thread t8 = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					long duration = 0;
					do {
						SaveDataForHBase.saveData("");
						duration = System.currentTimeMillis() - startTime;
					} while (duration < workTime);
					System.out.println("8用时：" + duration);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		});
		Thread t9 = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					long duration = 0;
					do {
						SaveDataForHBase.saveData("");
						duration = System.currentTimeMillis() - startTime;
					} while (duration < workTime);
					System.out.println("9用时：" + duration);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		});
		Thread t10 = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					long duration = 0;
					do {
						SaveDataForHBase.saveData("");
						duration = System.currentTimeMillis() - startTime;
					} while (duration < workTime);
					System.out.println("10用时：" + duration);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		});
		Thread t11 = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					long duration = 0;
					do {
						SaveDataForHBase.saveData("");
						duration = System.currentTimeMillis() - startTime;
					} while (duration < workTime);
					System.out.println("11用时：" + duration);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		});
		Thread t12 = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					long duration = 0;
					do {
						SaveDataForHBase.saveData("");
						duration = System.currentTimeMillis() - startTime;
					} while (duration < workTime);
					System.out.println("12用时：" + duration);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		});
		Thread t13 = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					long duration = 0;
					do {
						SaveDataForHBase.saveData("");
						duration = System.currentTimeMillis() - startTime;
					} while (duration < workTime);
					System.out.println("13用时：" + duration);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		});
		Thread t14 = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					long duration = 0;
					do {
						SaveDataForHBase.saveData("");
						duration = System.currentTimeMillis() - startTime;
					} while (duration < workTime);
					System.out.println("14用时：" + duration);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		});
		Thread t15 = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					long duration = 0;
					do {
						SaveDataForHBase.saveData("");
						duration = System.currentTimeMillis() - startTime;
					} while (duration < workTime);
					System.out.println("15用时：" + duration);
					System.err.println("存储条数" + SaveDataForHBase.num);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		});
		
		t1.start();
		t2.start();
		t3.start();
		t4.start();
		t5.start();
		t6.start();
		t7.start();
		t8.start();
		t9.start();
		t10.start();
		t11.start();
		t12.start();
		t13.start();
		t14.start();
		t15.start();
	}
 
	public void s() {
		long duration = 0;
		int num = 1;
		long startTime = System.currentTimeMillis();
		long currTime = 0;
		do {
			num++;
			try {
				SaveDataForHBase.saveData("");
			} catch (IOException e) {
				e.printStackTrace();
			}
			currTime = System.currentTimeMillis();
			duration = (currTime - startTime);
		} while (duration < 10000);
	}
	

}
